package com.jcoinexchage.user.controller.web;

import com.jcoinexchage.user.common.vo.EchoRes;
import com.jcoinexchange.web.entity.BasicResponse;
import com.jexchange.dubboapi.service.market.MarketPingPongDubboService;
import com.jexchange.dubboapi.service.match.MatchPingPongDubboService;
import com.jexchange.dubboapi.service.trade.TradePingPongDubboService;
import com.jexchange.dubboapi.service.wallet.WalletPingPongDubboService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;
import java.util.List;


@Tag(name = "测试接口")
@RestController
public class EchoController {


    @DubboReference
    private MarketPingPongDubboService marketPingPongDubboService;

    @DubboReference
    private TradePingPongDubboService tradePingPongDubboService;

    @DubboReference
    private MatchPingPongDubboService matchPingPongDubboService;

    @DubboReference
    private WalletPingPongDubboService walletPingPongDubboService;

    @Operation(summary = "打印信息")
//    @ApiResponses({
////            @ApiResponse(responseCode = "200", message = "success", response = EchoRes.class),
////            @ApiResponse(responseCode = "401", message = "xxx具体错误")
//    })
    @GetMapping("/echo")
    public BasicResponse<EchoRes> echo() {
        EchoRes echoRes = new EchoRes();
        List<String> pongs = new LinkedList<>();
        pongs.add(marketPingPongDubboService.ping());
        pongs.add(tradePingPongDubboService.ping());
        pongs.add(matchPingPongDubboService.ping());
        pongs.add(walletPingPongDubboService.ping());
        echoRes.setPongs(pongs);
        return BasicResponse.success(echoRes);
    }

}
